package com.example.testdiyexceltableheader.demos.excel.read;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.example.testdiyexceltableheader.demos.model.Target;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Getter
public class TestRowDataListListener extends AnalysisEventListener<Map<Integer, String>> {

    private List<Target> headList;

    private List<List<String>> data = new ArrayList<>();

    private List<Map<Integer, String>> record = new ArrayList<>();

    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        super.invokeHeadMap(headMap, context);
    }

    @Override
    public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {

        System.out.println("headMap = " + headMap);
        super.invokeHead(headMap, context);
    }

    @Override
    public void invoke(Map<Integer, String> data, AnalysisContext context) {

        record.add(data);
        System.out.println("data = " + data);
    }


    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

        System.out.println("context = " + context);
    }
}
